﻿@model Inscriptionem.Models.Blog.Views.CategoryViewModel

@{
    ViewBag.Title = Inscriptionem.Configuration.Configuration.Instance.General.Title + " » " + Model.SectionLocalizedName + " » " + Model.Category.Name;
    ViewBag.SearchText = "Search";
    Layout = "Layout.cshtml";
}

<div class="outer" id="contentwrap">
    <div class="sidecont">
		<div class="sidebar sidebar-left">
		    @{Html.RenderPartial("Controls/LeftMenu", Model);}
			<div class="sidebaradbox"></div>
		</div>
    </div>
    <div class="postcont">
		<div id="content">
        @if (Model.Articles.Any())
        {
            foreach (var article in Model.Articles)
            {
                var articleURL = string.Format("/{0}/{1}/{2}/{3}",
                Model.Language,
                Model.Section,
                article.Type.ToString(),
                article.ID);
                
            <text>
			<div class="post type-post status-publish format-standard hentry" id="post-@article.ID">
                <h2 class="title"><a href="@articleURL" rel="bookmark" title="Постоянная ссылка на @article.Title">@article.Title</a></h2>
                <div class="postdate">
                    <img src="/Content/Themes/General/Images/date.png"> @article.CreatedDate.ToShortDateString()
                    <img src="/Content/Themes/General/Images/folder.png"> 

                    @if (article.Categories.Any())
                    {
                        var categoriesList = new List<string>();   
                        foreach (var category in article.Categories.OrderBy(c => c.ID))
                        {
                            categoriesList.Add(string.Format("<a href=\"/{0}/{1}/Category/{2}\" title=\"Все посты в {3}\" rel=\"category tag\">{3}</a>",
                                Model.Language,
                                Model.Section,
                                category.ID,
                                category.Name));
                        }
                        <text>@Html.Raw(string.Join(", ", categoriesList.ToArray()))</text>
                    }

                    <img src="/Content/Themes/General/Images/comments.png"> 
                    <a href="@articleURL/#respond" title="Comment on @article.Title">@(article.CommentsCount == 0 ? "Нет комментариев »" : (string.Format("Комментарии: {0} »", article.CommentsCount)))</a>
                </div>
				<div class="entry">
                    @{
                        <text>@Html.Raw(article.Content)</text>
                    }
                    <p></p>
                    <p> <a href="@articleURL/#more-@article.ID" class="more-link">Читать дальше »</a></p>
	            </div>
			</div>
            </text>
            }
			<text>
            <div class="navigation">
            @{Html.RenderAction("Pagination",
                    new Inscriptionem.Models.Menu.Requests.PaginationRequestModel() {
                        Language = Model.Language,
                        Section = Model.Section,
                        CurrentPage = Model.Pagination.CurrentPage,
                        TotalPages = Model.Pagination.TotalPages,
                        MaximumLinkCount = 7,
                        UrlTemplate = "/{Language}/{Section}/Category/" + Model.Category.ID + "/{ID}"
                        });
            }
			</div>
            </text>
        }
        else
        { 
            <text>
            <div style="width: 100%;">
                <h2 style="text-align: center !important; color: #AF3530 !important;">Здесь ничего нет :)</h2>
            </div>
            </text>
        }
        </div>
	</div>	
	<div class="sidecont rightsector">
		<div class="sidebar sidebar-right">
            @{Html.RenderPartial("Controls/RightMenu", Model);}
		    <div class="sidebaradbox"></div>
		</div>
	</div>
</div>